import { Injectable } from '@angular/core';
import { RequestService } from '../../../cores/services/request.service';
import { ApiData } from '../../../cores/classes/api-data.class';
import { SearchParams } from '../../../cores/classes/search-params';
import { Inventory } from '../interfaces/inventory.interfaces';
import { Observable } from 'rxjs';
import { Pagination } from 'ng-tui';

@Injectable()
export class InventoryService {

    constructor(private request: RequestService) { }

    /**
     * 期初库存列表分页
     */
    searchCompany(pagination: Pagination, search: SearchParams): Observable<ApiData> {
        return this.request.get('/managerapi/early/stage/inventory/search', pagination.getpageDataWith(search.values));
    }
    /**
    * 获取指定商户（公司）
    */
    getCompany(companyId: number): Observable<ApiData> {
        return this.request.get('/admin/company/get', { companyId });
    }

    // /**
    //  * 请求添加期初库存列表
    //  */
    // insertCompany(company: Inventory): Observable<ApiData> {
    //     return this.request.post('/managerapi/early/stage/inventory/add', company);
    // }
    /**
      * 添加期初库存
      *
      */
    insertinven(inventory: Inventory): Observable<ApiData> {
        return this.request.post('/managerapi/early/stage/inventory/add', inventory);
    }
    /**
         * 仓库列表
         */
    addhouse(): Observable<ApiData> {
        return this.request.url('/managerapi/warehouse/get');
    }
    /**
    * 编辑期初库存
    *
    */
    updateinven(inventory: Inventory): Observable<ApiData> {
        return this.request.put('/managerapi/early/stage/inventory/update', inventory);
    }

    /**
     * 删除库存
     */
    deleteinventory(id: number): Observable<ApiData> {
        return this.request.delete('/managerapi/early/stage/inventory/delete', { id });
    }
    /**
     * 更新商户信息（公司）
     */
    updateCompany(company: Inventory): Observable<ApiData> {
        return this.request.put('/admin/company/update', company);
    }

    /**
     * 删除商户信息（公司）
     */
    deleteCompany(companyId: number): Observable<ApiData> {
        return this.request.delete('/admin/company/delete', { companyId });
    }

    /**
     * 上传商户图片
     */
    uploadCompayLogo(file: File): Observable<string> {
        return this.request.ossUpload('/admin/company/image/access', file);
    }
    /**
  * 资产列表
  */
    searchPlatformManager(pagination: Pagination, search: SearchParams): Observable<ApiData> {
        return this.request.get('/managerapi/early/stage/asset/search', pagination.getpageDataWith(search.values));
    }
    /**
     * 添加期初库存
     *
     */
    stageadd(inventory: Inventory): Observable<ApiData> {
        return this.request.post('/managerapi/early/stage/asset/add', inventory);
    }
    /**
    * 编辑期初库存
    *
    */
    updatestage(inventory: Inventory): Observable<ApiData> {
        return this.request.put('/managerapi/early/stage/asset/update', inventory);
    }
    /**
        * 删除库存
        *
        */
    deletestage(id: number): Observable<ApiData> {
        return this.request.delete('/managerapi/early/stage/asset/delete', { id });
    }
}
